package com;

import com.controlier.ServerChannelHandler;
import com.domain.Equip_data;
import com.domain.Global_data;
import com.utilus.NettyTcpClient;
import com.utilus.NettyTcpServer;
import com.utilus.usart.Usart;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

import java.util.ArrayList;
import java.util.List;

@EnableConfigurationProperties({Global_data.class,Equip_data.class})
@SpringBootApplication
// public class MysqlApplication {
   public class MysqlApplication implements CommandLineRunner {

    public  static List<Equip_data> equip_list=new ArrayList<>();//系统类型

    public  static Global_data global_data=new Global_data();//系统类型


    @Autowired
    Usart usart;
    @Autowired
    ServerChannelHandler serverChannelHandler;


    public static void main(String[] args) throws Exception {

        SpringApplication.run(MysqlApplication.class, args);
        System.out.println("----------------------------------------------------\n");
        System.out.println("程序运行成功——张云灏  \n");
        System.out.println("----------------------------------------------------");



        System.out.println("用户的主目录:"+System.getProperty("user.home"));
        System.out.println("用户的当前工作目录:"+System.getProperty("user.dir"));
        System.out.println("当前的classpath的绝对路径的URI表示法:" + Thread.currentThread().getContextClassLoader().getResource(""));





    }
//    public void run(String... args) throws Exception {
//        ChannelFuture start = nettyTcpServer.start();
//        start.channel().closeFuture().syncUninterruptibly();
//    }


    public void run(String... args) throws Exception {

        serverChannelHandler .tcp_init();

//        usart.usart_init( );

        //启动服务端
//        ChannelFuture start = nettyTcpServer.start();
//        //启动客户端，发送数据
//       nettyTcpClient.connect();
        //服务端管道关闭的监听器并同步阻塞,直到channel关闭,线程才会往下执行,结束进程
//        start.channel().closeFuture().syncUninterruptibly();


    }

//    int head;       //头2
//    int batch;      //批次1
//    int kind;       //种类，2
//    int open;       //开关1
//    int speed;      //速度2
//    int clour;      //颜色6
//    int lenth;      //长度2
//    String content; //内容
//    int check;      //校验2
//    int tail;       //结尾1
}
